#include "UnitTest++.h"
#include "PathBuilder.h"
#include <stdio.h>

std::vector<FilePathData> buildFilePathDataVector()
{
    FilePathData data;
    data.fullPath_ = "resources/TestDirectory/";
    data.relativePath_ = "TestDirectory/";
    FilePathData data2;
    data2.fullPath_ = "resources/TestDirectory/b/";
    data2.relativePath_ = "TestDirectory/b/";
    FilePathData data3;
    data3.fullPath_ = "resources/TestDirectory/b/b2.txt";
    data3.relativePath_ = "TestDirectory/b/b2.txt";

    std::vector<FilePathData> vector;
    vector.push_back(data);
    vector.push_back(data2);
    vector.push_back(data3);

    return vector;
}

TEST(ShouldFillAVectorWithTheRigthPathsToCompress)
{
    std::string directoryPath = "resources/";
    PathBuilder pathBuilder(directoryPath);
    std::vector<FilePathData> pathData;

    pathBuilder.buildPaths("resources/TestDirectory/", pathData);

    std::vector<FilePathData> expectedVector = buildFilePathDataVector();

    for (int i = 0; i < expectedVector.size(); i++)
    {
        CHECK(expectedVector.at(i) == pathData.at(i));
    }

}

TEST(ShouldFillAVectorWithTheRigthPathsToCompressWithAFile)
{
    std::string directoryPath = "resources/";
    PathBuilder pathBuilder(directoryPath);
    std::vector<FilePathData> pathData;

    pathBuilder.buildPaths("resources/file2.txt", pathData);

    FilePathData data;
    data.fullPath_ = "resources/file2.txt";
    data.relativePath_ = "file2.txt";

    CHECK(pathData.at(0) == data);

}

TEST(ShouldFillAVectorWithTheRigthPathsToCompressWithAFileAndADirectory)
{
    std::string directoryPath = "resources/";
    PathBuilder pathBuilder(directoryPath);
    std::vector<FilePathData> pathData;

    pathBuilder.buildPaths("resources/TestDirectoryFileHeader", pathData);

    FilePathData data;
    data.fullPath_ = "resources/TestDirectoryFileHeader";
    data.relativePath_ = "TestDirectoryFileHeader";
    FilePathData data2;
    data2.fullPath_ = "resources/TestDirectoryFileHeader/test";
    data2.relativePath_ = "TestDirectoryFileHeader/test";

    for (std::vector<FilePathData>::iterator it = pathData.begin(); it != pathData.end(); it++)
    {
        printf("FULL PATH: %s\nRELATIVE PATH: %s\n",(*it).fullPath_.c_str(),(*it).relativePath_.c_str());
    }

    CHECK(pathData.at(0) == data);
    CHECK(pathData.at(1) == data2);

}

TEST(ShouldFillAVectorWithTheRigthPathsToCompressWithSeveralFilesAndDirectories)
{
    std::string directoryPath = "resources/";
    PathBuilder pathBuilder(directoryPath);
    std::vector<FilePathData> pathData;

    pathBuilder.buildPaths("resources/TestCompress", pathData);


    for (std::vector<FilePathData>::iterator it = pathData.begin(); it != pathData.end(); it++)
    {
        printf("FULL PATH: %s\nRELATIVE PATH: %s\n",(*it).fullPath_.c_str(),(*it).relativePath_.c_str());
    }


}